<?php 
	import('TagLib');
	class TagLibHd extends TagLib{
		protected $tags=array(
			'nav'=>array('attr'=>'order','close'=>1),
			'hot'=>array('attr'=>'type','close'=>1),
			'tag'=>array('attr'=>'','colse'=>1),
			);

		public function _nav(){
			$cate=M('cate')->order('sort ASC')->select();
			import('Class.Category',APP_PATH);
			$cate=Category::unlimitedForLevel($cate);
			$str='$cate=array(';
			foreach ($cate as $k=>$v) {
				if($v['level']==1){
					$str.='array("name"=>"'.$v['name'].'","id"=>'.$v['id'].',';
					$str.='"child"=>array(';
					foreach ($cate as $l) {
						if($l['pid']==$v['id'])
						$str.='array("name"=>"'.$l["name"].'","id"=>'.$l['id'].'),';
					}
					$str.=")),";
				}
			}
			return '<?php '.$str.')?>';
		}
		public function _hot($attr,$content){
			$attr=$this->parseXmlAttr($attr);
			$blog=M('blog')->field(array('id','time','title','click'))->where(array("del"=>0))->order($attr['type'].' DESC')->select();
			$str="";
			foreach ($blog as $v) {
				$str.="<?php ";
				$str.='$id="'.$v["id"].'";';
				$str.='$title="'.$v["title"].'";';
				$str.='$time="'.$v["time"].'";';
				$str.='$click="'.$v["click"].'";?>';
				$str.=$content;
			}
			return $str;
		}

		public function _tag(){
			$str="";
			foreach (C('hot') as  $value) {
				$str.='$tags[]="'.$value.'";';
			}
			return "<?php ".$str."?>";
		}
	}